﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="RangeRandom.aspx.cs" Inherits="RangeRandom" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>指定范围的随机数</title>
    <script src="jquery-1.6.2.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(function () {

            $("#btn1").click(function () {
                var start = parseInt($("#txt1").val())-1;
                var end = parseInt($("#txt2").val());

                var res = Math.ceil(start + (end - start) * Math.random());
                alert(res);
            });
        });
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <input type="text" id="txt1" value="1" />
        <input type="text" id="txt2" value="10" />
        <input id="btn1" type="button" value="生成" />
    </div>
    </form>
</body>
</html>
